package com.ruoyi.jx.controller;

import java.util.List;
import java.util.Map;

import com.ruoyi.jx.domain.MemberBalanceRecordVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jx.domain.MemberBalanceRecord;
import com.ruoyi.jx.service.IMemberBalanceRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员余额Controller
 * 
 * @author p
 * @date 2021-10-07
 */
@RestController
@RequestMapping("/jx/memberBalanceRecord")
public class MemberBalanceRecordController extends BaseController
{
    @Autowired
    private IMemberBalanceRecordService memberBalanceRecordService;

    /**
     * 查询会员余额列表
     */
    @PreAuthorize("@ss.hasPermi('jx:memberBalanceRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberBalanceRecord memberBalanceRecord)
    {
        startPage();
        List<MemberBalanceRecord> list = memberBalanceRecordService.selectMemberBalanceRecordList(memberBalanceRecord);
        return getDataTable(list);
    }

    @GetMapping("/list-map")
    public TableDataInfo listMap(@RequestParam Map<String,Object> params)
    {
        startPage();
        List<MemberBalanceRecordVO> list = memberBalanceRecordService.selectMemberBalanceRecordListMap(params);


        return getDataTable(list);
    }

    /**
     * 导出会员余额列表
     */
    @PreAuthorize("@ss.hasPermi('jx:memberBalanceRecord:export')")
    @Log(title = "会员余额", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MemberBalanceRecord memberBalanceRecord)
    {
        List<MemberBalanceRecord> list = memberBalanceRecordService.selectMemberBalanceRecordList(memberBalanceRecord);
        ExcelUtil<MemberBalanceRecord> util = new ExcelUtil<MemberBalanceRecord>(MemberBalanceRecord.class);
        return util.exportExcel(list, "memberBalanceRecord");
    }

    /**
     * 获取会员余额详细信息
     */
    @PreAuthorize("@ss.hasPermi('jx:memberBalanceRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(memberBalanceRecordService.selectMemberBalanceRecordById(id));
    }

    /**
     * 新增会员余额
     */
    @PreAuthorize("@ss.hasPermi('jx:memberBalanceRecord:add')")
    @Log(title = "会员余额", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberBalanceRecord memberBalanceRecord)
    {
        return toAjax(memberBalanceRecordService.insertMemberBalanceRecord(memberBalanceRecord));
    }

    /**
     * 修改会员余额
     */
    @PreAuthorize("@ss.hasPermi('jx:memberBalanceRecord:edit')")
    @Log(title = "会员余额", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberBalanceRecord memberBalanceRecord)
    {
        return toAjax(memberBalanceRecordService.updateMemberBalanceRecord(memberBalanceRecord));
    }

    /**
     * 删除会员余额
     */
    @PreAuthorize("@ss.hasPermi('jx:memberBalanceRecord:remove')")
    @Log(title = "会员余额", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberBalanceRecordService.deleteMemberBalanceRecordByIds(ids));
    }
}
